package com.zhn.evsi.utils;

import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;


/**
 * 时间格式
 * */
@Component
public class TimeUtil {

    /**
     * Time second
     * */
    public String TimeFormatOnSecond() {

        // 时间设置
        Date now = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8"));
        return simpleDateFormat.format(now);
    }

    /**
     * Time minute
     * */
    public String TimeFormatOnMinute() {

        // 时间设置
        Date now = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8"));
        return simpleDateFormat.format(now);
    }

    /**
     * Time hour
     * */
    public String TimeFormatOnHour() {

        // 时间设置
        Date now = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH");
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8"));
        return simpleDateFormat.format(now);
    }

    /**
     * Time day
     * */
    public String TimeFormatOnDay() {

        // 时间设置
        Date now = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8"));
        return simpleDateFormat.format(now);
    }
}
